package com.difsonapps.contacttranslator.ws.rest;

import java.util.List;
import java.util.Random;

import org.apache.log4j.Logger;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.difsonapps.contacttranslator.component.MailService;
import com.difsonapps.contacttranslator.dto.EventDTO;
import com.difsonapps.contacttranslator.dto.MessageDTO;
import com.difsonapps.contacttranslator.dto.UserDTO;
import com.difsonapps.contacttranslator.dto.UserTransactionDTO;
import com.difsonapps.contacttranslator.service.itf.EventService;
import com.difsonapps.contacttranslator.service.itf.UserService;
import com.difsonapps.contacttranslator.service.itf.UserTransactionService;
import com.difsonapps.contacttranslator.utils.CommonProps;
import com.difsonapps.contacttranslator.utils.Constant;
import com.difsonapps.contacttranslator.utils.FCMessage;
import com.difsonapps.contacttranslator.utils.Utils;

@Controller
@RequestMapping("/event")
public class EventCtrl {

	@Autowired
	EventService eventService;
	
	@Autowired
	CommonProps commonProps;

	Logger logger = Logger.getLogger(getClass());


	@RequestMapping( method = RequestMethod.GET, value="notification/lastid/{lastid}")
	public @ResponseBody List<EventDTO> getNotification(
			@PathVariable int lastid) {
		List<EventDTO> listEvent=null;
		try {
			if(lastid<=0){
				listEvent = eventService.getLimit(commonProps.maxEvent);
			}else
				listEvent = eventService.getByLastId(lastid,commonProps.maxEvent);
		} catch (Exception e) {
			logger.info(e.getMessage(), e);
		}
		return listEvent;
	}

}
